﻿@using Orchard.ContentManagement
@using Orchard.Layouts.Helpers
@using Orchard.MediaLibrary.Models
@{
    var tagBuilder = TagBuilderExtensions.CreateElementTagBuilder(Model, "img");
    var imagePart = (ImagePart)Model.ImagePart;
    var mediaPart = imagePart != null ? imagePart.As<MediaPart>() : default(MediaPart);

    if (mediaPart != null) {
        tagBuilder.Attributes["src"] = Url.Content(mediaPart.MediaUrl);
        tagBuilder.Attributes["alt"] = mediaPart.AlternateText;
    }
    else {
        tagBuilder.Attributes["alt"] = T("Image not found").Text;
    }
    
    tagBuilder.AddCssClass("layout-content-image");
}
@tagBuilder.ToHtmlString(TagRenderMode.SelfClosing)
